package com.xt.LibaryDeskManager.servlet;

import com.xt.LibaryDeskManager.dto.DepartmentDto;
import com.xt.LibaryDeskManager.service.DepartmentService;
import com.xt.LibaryDeskManager.utils.StrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/dept")
public class DepartMentController {
    @Autowired
    private DepartmentService departmentService;
    /**
     * 根据上级部门id，获取所有部门
     */
    @ResponseBody
    @RequestMapping("/getAllDepart")
    public Map getAllDepart(Integer pid) throws Exception {
        List<DepartmentDto> list= departmentService.getAll(pid);
        return StrUtils.creatMessage("list",list);
    }
}
